<template>
  <div>
    <div class="menu">
      <div v-for="item in this.$store.state.routes" :key="item.name">
        <router-link :to="item.path">{{item.name}}</router-link>
      </div>
    </div>
    <div>
      <h3>this is home page</h3>
    </div>
    <div>
      <button @click="logout">退出登录</button>
    </div>
  </div>
</template>

<script>
import store from '@/store';
import Cookies from 'js-cookie';

export default {
  name: 'Home',
  methods: {
    logout() {
      Cookies.remove('token');
      Cookies.remove('id');
      localStorage.removeItem('menu');
      store.dispatch('resetRoutes');

      this.$router.push('/login');
    }
  }
}
</script>


